﻿@model List<Notification>

@{
    ViewData["Title"] = "Notification";
}

<div class="container">
    <h1 class="display-4">Notification</h1>
    <br />

    @if (Model.Count == 0)
    {
        <h5>There is nothing here.</h5>
    }
    else
    {
        <a asp-action="DeleteAll">Delete All</a>
        <br /><br />

        @foreach (var notification in Model)
        {
            <div class="card mb-4">
                <div class="card-header font-weight-bolder">
                    @notification.Title
                    <span class="float-right">
                        @notification.Time.ToString("yyyy/MM/dd")
                    </span>
                </div>
                <div class="card-body">
                    <div class="markdown">
                        <textarea hidden>@notification.Content</textarea>
                    </div>

                    @await Component.InvokeAsync("FormLink", new FormLink()
                    {
                        Href = "/Admin/Notification/Delete/",
                        Text = "Delete",
                        Warning = "Confirm deletion?",
                        ClassName = "btn btn-danger float-right",
                        Paras = new() 
                        {
                            { "id", notification.Id.ToString() }
                        }
                    })
                </div>
            </div>
        }
    }

    <partial name="MarkdownRender" />

</div>

